package com.tour.controller.portal;

import javax.annotation.Resource;
import javax.servlet.http.HttpSession;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import com.tour.common.Const;
import com.tour.common.ServerResponse;
import com.tour.pojo.User;
import com.tour.service.IOrderService;

/**
 * Created by fivedeath
 */
@Controller
@RequestMapping("/order/")
public class OrderController {
	
   @Resource
   IOrderService orderService;
   
   @RequestMapping(value="getOrderCount.do")
   @ResponseBody
   public ServerResponse getOrderCount(HttpSession session){
	System.out.println("+++++++++++++++++");
	  User user = (User) session.getAttribute(Const.CURRENT_USER);
	   return  orderService.getOrderCount(user.getUserId());
   }
   
   @RequestMapping(value="getOrderList.do")
   @ResponseBody
   public ServerResponse getOrderList(HttpSession session,@RequestParam(value="nowPage",defaultValue="1") int page,@RequestParam(value="size",defaultValue="2") int rows){
	   User user = (User) session.getAttribute(Const.CURRENT_USER);
	   System.out.println("============================="+page+"++++++++++++++"+rows);
	   return orderService.selectByUserId(user.getUserId(), page, rows);
   }
}
